Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blueprints: add Blueprints filtering #1607

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

ezr-ondrej
Copy link
Collaborator

@ezr-ondrej ezr-ondrej commented Jan 29, 2024

Enables Blueprints filtering.
Given this is a server side filtering, it also adds Debounce hook.
This hook enables delay the API request to save server roundtrips.

Refs HMS-3389

Screencast.from.2024-01-30.10-19-03.webm

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ezr-ondrej ! looks and works great 👍
I left a few inline comments, and also I've found a small glitch once clearing the search input:

Screen.Recording.2024-01-29.at.14.43.21.mov

Comment on lines 60 to 61
const [searchQuery, blueprintsFilter, setBlueprintsFilter] =
useDebouncedSearch('', 500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block this custom hook, but lodash has debounce implementation already, why not using it and keep it as regular state?

import _debounce from 'lodash/debounce';

    const debounceFn = useCallback(_debounce(setBlueprintsFilter, 500), []);
        <SearchInput
             placeholder="Search by name or description"
             value={filter}
             onChange={(_event, value) => debounceFn(value)}
             onClear={() => onChange('')}

Copy link
Member

@amirfefer amirfefer Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, 500 ms feels a bit long to me, would 300 be better? Thinking of this delay (and also fetching time), how would be adding a spinner or another indicator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I did not find a way how to use lodash debounce 😛
Definitelly on looks better, let me improve it! 👍

Copy link
Member

@amirfefer amirfefer Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)
I'm thinking that backend and frontend filtering would work the best together , we already have up to 100 blueprints records in the store by default, we can filter it locally by default for instant result, and update the store if there were any updates from the debounced query. though I think this enhancement can be implemented as a follow up as part of general optimistic updating refactor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's IMO amazing idea, we should discuss it with Andrew Dewar, he did quite a lot of optimistic updating, we can get some lessons learned :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow... it's amazing, just 200 ms less and it really feels much smoother experience.
So I've read about it because I was amazed and I've learned that smooth feeling is when the interaction computer <-> human is below 400ms, cool

src/Components/LandingPage/LandingPage.tsx Outdated Show resolved Hide resolved
@@ -61,7 +81,7 @@ const BlueprintsSidebar = ({
<StackItem>
<SearchInput
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice a addition for the search input is adding the resultsCount prop for rendering a counter badge, i.e
Screenshot 2024-01-29 at 14 42 54

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used count blueprints it feels more user friendly, but kinda long, so I'm not strongly for that, happy to go just with the number if you'd think it's better ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, feels friendly and verbose, but a bit too long IMHO

onClear={() => onChange('')}
/>
</StackItem>
<StackItem>No Blueprints found</StackItem>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using the empty state design ?
Screenshot 2024-01-29 at 14 46 53

@ezr-ondrej ezr-ondrej force-pushed the blueprint_filtering branch 2 times, most recently from de521a7 to 3236536 Compare January 30, 2024 09:18
@ezr-ondrej
Copy link
Collaborator Author

Thanks for the amazing pointers Amir, I've incorporated almost all of them :)
Just the optimistic search is missing, but that would be an amazing followup IMO - as you say, we will have most of the blueprints loaded in majority of cases :)

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ezr-ondrej ! works smoothly indeed 👍
just a minor nitpick

}: blueprintProps) => {
const [blueprintFilter, setBlueprintFilter] = useState('');
const blueprintsCount = blueprints?.length || 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the fetched data length, we can use the meta object for the query search count :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're completely right! :)
Adding that.

@@ -85,6 +102,8 @@ export const LandingPage = () => {
blueprints={blueprints?.data}
selectedBlueprint={selectedBlueprint}
setSelectedBlueprint={setSelectedBlueprint}
filter={blueprintsSearchQuery}
Copy link
Member

@amirfefer amirfefer Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e, adding -

blueprintsCount={blueprints?.meta.count}

@ezr-ondrej
Copy link
Collaborator Author

hmm while adding the blueprintsTotal, I've realized we can move the query to the sidebar, the only information is the selected blueprint. So I've moved everything else down to the sidebar component.

It looks bit cleaner on the LandingPage component side.
I didn't change anything, just moved the query and added the total. WDYT? :)

Copy link
Member

@amirfefer amirfefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @ezr-ondrej 👍

@lavocatt lavocatt force-pushed the blueprint_filtering branch from 3af6c24 to f0fd731 Compare February 1, 2024 08:48
@lavocatt
Copy link
Contributor

lavocatt commented Feb 1, 2024

Thanks for working on this! I've got an issue with the filter not filtering on msw :
Screencast from 2024-02-01 10-02-23.webm
to reproduce, spin up the frontend with npm run stage-beta:msw+experimental

@ezr-ondrej
Copy link
Collaborator Author

to reproduce, spin up the frontend with npm run stage-beta:msw+experimental

For me it still loads up data from the server 🤔

@ezr-ondrej
Copy link
Collaborator Author

/retest

1 similar comment
@lavocatt
Copy link
Contributor

lavocatt commented Feb 1, 2024

/retest

@ezr-ondrej ezr-ondrej force-pushed the blueprint_filtering branch 3 times, most recently from f6eb8da to c22f12f Compare February 1, 2024 16:16
@ezr-ondrej
Copy link
Collaborator Author

/retest

Copy link
Contributor

@lavocatt lavocatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 This works great! Thanks a lot.

@lavocatt
Copy link
Contributor

lavocatt commented Feb 2, 2024

/retest

1 similar comment
@ezr-ondrej
Copy link
Collaborator Author

/retest

Enables Blueprints filtering.
Given this is a server side filtering, it also ads Debounce hook.
This hook enables delay the API request to save server roundtrips.

Refs HMS-3389
@regexowl regexowl force-pushed the blueprint_filtering branch from c22f12f to 80d785f Compare February 2, 2024 11:56
@lavocatt
Copy link
Contributor

lavocatt commented Feb 2, 2024

/retest

@lavocatt
Copy link
Contributor

lavocatt commented Feb 2, 2024

@jrusz can you have a look at why the tests are failing please? We've been restarting them a bunch of time without any success.

@jrusz
Copy link
Collaborator

jrusz commented Feb 2, 2024

@jrusz can you have a look at why the tests are failing please? We've been restarting them a bunch of time without any success.

Yeah there is some more widespread issue happening, other consoledot apps are seeing the same issue in their pr_check jobs... Nobody seems to know what's wrong yet... I believe that this should be ok to merge though as this should be behind the feature flag.

@lavocatt
Copy link
Contributor

lavocatt commented Feb 2, 2024

Yeah there is some more widespread issue happening, other consoledot apps are seeing the same issue in their pr_check jobs... Nobody seems to know what's wrong yet... I believe that this should be ok to merge though as this should be behind the feature flag.

Thanks for the heads up, I'm merging then.

@lavocatt lavocatt merged commit c447244 into osbuild:main Feb 2, 2024
2 of 3 checks passed
@ezr-ondrej ezr-ondrej deleted the blueprint_filtering branch February 2, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants